/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.scalia.meteocal.entity;

import com.scalia.meteocal.control.PasswordEncrypter;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 *
 * @author gabriele
 */
@Entity(name = "INVITATION")
@NamedQueries({
        @NamedQuery(name = Invitation.findAll, query = "SELECT i FROM INVITATION i where i.event.deleted = false"),
        @NamedQuery(name = Invitation.findAllInvitationsOfUser, query = "SELECT i FROM INVITATION i WHERE i.user = :user and i.event.deleted = false"),
        @NamedQuery(name = Invitation.findAllInvitationsOfEvent, query = "SELECT i FROM INVITATION i WHERE i.event = :event and i.event.deleted = false"),
        @NamedQuery(name = Invitation.findAnInvitation, query = "SELECT i FROM INVITATION i WHERE i.event = :event and i.user = :user and i.event.deleted = false"),
})
public class Invitation implements Serializable {

    private static final long serialVersionUID = 1L;
    public static final String findAll = "findAllInvitations";
    public static final String findAllInvitationsOfUser = "findAllInvitationsOfUser";
    public static final String findAllInvitationsOfEvent = "findAllInvitationsOfEvent";
    public static final String findAnInvitation = "findAnInvitation";
    @Id
    private Event event;
    
    @Id
    private User user;
    
    @NotNull(message = Messages.NOT_EMPTY)
    private boolean accepted;

    @Temporal(TemporalType.TIMESTAMP)
    @NotNull(message = Messages.NOT_EMPTY)
    private Date creationTimestamp;

    public Event getEvent() {
        return event;
    }

    public void setEvent(Event event) {
        this.event = event;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public boolean isAccepted() {
        return accepted;
    }

    public void setAccepted(boolean accepted) {
        this.accepted = accepted;
    }

    public Date getCreationTimestamp() {
        return creationTimestamp;
    }

    public void setCreationTimestamp(Date creationTimestamp) {
        this.creationTimestamp = creationTimestamp;
    }
}
